var _width_ = 0;
var _width = 0;
var tree_width_ = 0;
var winWidth = 0;
var winHeight = 0;
var treeHeight = 0;
var t = 0;
var navHeight = 0;
var specW = 0;
var btnW = 0;
var infoScroll;
var infoScroll2;
function findDimensions() {	
	// 获取窗口宽度
	if (window.innerWidth) {
		winWidth = window.innerWidth;
	} else if ((document.body) && (document.body.clientWidth)) {
		winWidth = document.body.clientWidth;
	}
	// 获取窗口高度
	if (window.innerHeight) {
		winHeight = window.innerHeight;
	} else if ((document.body) && (document.body.clientHeight)) {
		winHeight = document.body.clientHeight;
	}
	// 通过深入Document内部对body进行检测，获取窗口大小
	if (document.documentElement && document.documentElement.clientHeight && document.documentElement.clientWidth) {
		winHeight = document.documentElement.clientHeight;
		winWidth = document.documentElement.clientWidth;
	}
	
	var cHeight = winHeight - 85;
	var iframeHeight = winHeight -20;
	var subScrollHeight = winHeight -65;
	var rWidth = winWidth - 162;
	
	//infoScroll = document.body.scrollHeight>document.body.clientHeight;//有滚动条;
	var obj = document.getElementById("subScroll");
	if(obj != null){
		infoScroll = obj.scrollHeight>subScrollHeight||obj.offsetHeight>subScrollHeight;//有滚动条;		
	}	
	
	var obj2 = document.getElementById("subTreeTable");
	if(obj2 != null){
		infoScroll2 = obj2.scrollHeight>subScrollHeight||obj2.offsetHeight>subScrollHeight;//有滚动条;		
	}		
	
	// 获取没有树的table宽度
	_width = winWidth - 204;
	if(_width < 690){					
		_width_ = 690;//设置table最小宽度；
	}else{
		if(infoScroll){
			_width_ = _width - 18;//判断是否存在滚动条，有滚动条时减去滚动条宽度；
		}else{
			_width_ = _width;
		}
	}
	
	//获取有数的table宽度
	tree_width = winWidth - 405;
	if(tree_width <= 690){
		tree_width_ = 690;
		specW = 660;
	}else{
		if(infoScroll){			
			tree_width_ = tree_width - 18;
			specW = tree_width_ - 58;
		}else{
			tree_width_ = tree_width;
			specW = tree_width_ - 40;
		}
	}		
	
	var jq_table_id = $("div.mainTable div").attr("id");
	if(jq_table_id != undefined){
		jq_table_id = jq_table_id.substring(5,jq_table_id.length);
	}
	
	if($("div.mainTable").parent().attr("class") == "tree_mainInfo"){
		if($("div.mainTable div:first").attr("class") == "tabsTable"){
			jQuery.util.setJqWidth("_stationGrid",specW);//tabs 嵌套Table
			btnW = specW -6;
			$("div.tabs_tree_btn").css({"width":btnW});
		}else{
			jQuery.util.setJqWidth(jq_table_id,tree_width_);//有树
		}
	}else{
		jQuery.util.setJqWidth(jq_table_id,_width_);//没有树		
	}

	//if(infoScroll2){
		//rWidth = rWidth - 18;
	//}else{
		//rWidth = rWidth;
	//}
	var resultTableWidth = rWidth - 240;
	if(resultTableWidth<=690){		
		resultTableWidth = 690;
	}else{
		if(infoScroll2){
			resultTableWidth = resultTableWidth -18;		
		}else{
			resultTableWidth = resultTableWidth;		
		}		
	}

	var treeHeight = (winHeight - 85) + "px";
	
	$("div.treeList").css({"height" : treeHeight});//有树Iframe 左边‘树’高度设置；
	$("table.treeListTable").css({"width" : rWidth});//有树Iframe table宽度设置；
	$("table.treeListTable div.tree_mainInfo").css({"height" : subScrollHeight});//有树Iframe右边 table 设置高度单独出滚动条
	$("table.resultTable").css({"width" : resultTableWidth});
	$("div.content").css({"height" : cHeight});
	$("div.dl-all").css({"height" : cHeight});
	$("div.rightContent").css({"width" : winWidth,"height" : iframeHeight});	
	$("#loadIframe").css({"width" : winWidth,"height" : iframeHeight});	
	$("div.cont_all").css({"width" :winWidth,"height" : iframeHeight});
	$("div.subScroll").css({"height" : subScrollHeight});

	var num = $("div.dl-all div.navList").size();
	navHeight = ((winHeight - 85) - (num * 30));
	$("ul.list").css({"height":navHeight});
	$("div.dd-title").css({"height":navHeight});
	
	arrayPageSize = new Array(winHeight, winWidth);
	return arrayPageSize;
}

$(document).ready(function() {	
	$("div#admin").hide();
	$("body").fixPng();
	findDimensions();
	window.onresize = findDimensions;
	// 左导航初始化
	$(".dd-title:not(:first)").hide();// 隐藏Nav UI
	$(".dd-title:first").show();// 显示Nav 第一个UI

	// 操作左导航标题
	$(".dt-title h3").click(function() {
		if($(this).attr("class") != "navOn"){		
			$("h3.navOn").removeClass("navOn");
			$(this).addClass("navOn");
			$(".dd-titleOn").removeClass("dd-titleOn");
			$(this).parent().next().addClass("dd-titleOn");
			$(".dd-title:visible").slideUp();
			$("div.dd-titleOn").slideDown();
			$(".navActiveOn").removeClass("navActiveOn");
			$("div.contList div._a_contList_a").show();
			$("#loadIframe").attr("src", $(".dd-titleOn ul li:eq(0)").addClass("navActiveOn").attr('url'));//+'&sid='+Math.random()
			//$("div.contList div._a_contList_a").empty().show().load($(".dd-titleOn ul li:eq(0)").addClass("navActiveOn").attr('url')+'&sid='+Math.random());
			return false;
		}
	});

	// 操作做导航子菜单
	$("ul.list li").click(function() {
		$(".navActiveOn").removeClass("navActiveOn");
		$(this).addClass("navActiveOn");
		$("div.contList div.infoList").hide();	
		$("div.contList div._a_contList_a").show();
		$("#loadIframe").attr("src", $(this).attr('url'));//+'&sid='+Math.random()
	});

	// 设置input:text 类型的样式
	//$("div.searchList ul li input:text").css({"width" : "148px","border" : "1px solid #74c1eb","background-color" : "#fff","line-height" : "20px","height" : "20px"});	
});
